
import { Component, Emit, Prop, Provide } from 'vue-property-decorator'
import { MyVue } from 'src/wl/my_vue'
import * as Api from 'src/api/net';
import { AccManageConst } from "src/consts/acc_manage_const";
@Component({})


export default class wl_main extends MyVue {
    timeLabel: String;
    nameLabel: String;
    auditNumber: String;

    initData(that?: any) {
        that.timeLabel = ""
        that.nameLabel = this.getUserInfo().userName + ""
        this.startTime();
        that.auditNumber = ""
    }

    audit(): void {
        this.$router.push('/audit/audit_manage');
    }

    created() {
        Api.authorityAjaxPost(Config.ajaxUrl + "/webaudit/audit/number/get.do", {}, (res: any) => {
            if (res.code === 0) {
                this.auditNumber = res.data + ""
            }
        });
    }

    testUrl(): void {
        let sendData: any = {}
        sendData["curr_page"] = 1
        sendData["page_size"] = 15
        WLDispatch(AccManageConst.DispatchList, sendData);
    }

    startTime(): void {
        var today = new Date(); //定义日期对象   
        var yyyy = today.getFullYear(); //通过日期对象的getFullYear()方法返回年    
        var MM = today.getMonth() + 1; //通过日期对象的getMonth()方法返回年    
        var dd = today.getDate(); //通过日期对象的getDate()方法返回年     
        var hh = today.getHours(); //通过日期对象的getHours方法返回小时   
        var mm = today.getMinutes(); //通过日期对象的getMinutes方法返回分钟   
        var ss = today.getSeconds(); //通过日期对象的getSeconds方法返回秒   
        // 如果分钟或小时的值小于10，则在其值前加0，比如如果时间是下午3点20分9秒的话，则显示15：20：09   
        MM = this.checkTime(MM);
        dd = this.checkTime(dd);
        mm = this.checkTime(mm);
        ss = this.checkTime(ss);
        var day; //用于保存星期（getDay()方法得到星期编号）
        if (today.getDay() == 0) day = "星期日 "
        if (today.getDay() == 1) day = "星期一 "
        if (today.getDay() == 2) day = "星期二 "
        if (today.getDay() == 3) day = "星期三 "
        if (today.getDay() == 4) day = "星期四 "
        if (today.getDay() == 5) day = "星期五 "
        if (today.getDay() == 6) day = "星期六 "
        this.timeLabel = yyyy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss + "   " + day
        //每一秒中重新加载startTime()方法 
        setTimeout(() => {
            this.startTime()
        }, 1000);
    }
    checkTime(i: any): number {
        if (i < 10) {
            i = "0" + i;
        }
        return i;
    }

    //获取用户信息
    getUserInfo(): any {
        var localStringData: any = localStorage.getItem("localUserData");
        var _serverData = JSON.parse(localStringData);
        var userInfo;
        if (_serverData) {
            userInfo = _serverData.data.userInfo;
        }

        return userInfo
    }
}
